package assignment8;

public class DoubleDispatching {
	//由v决定调用哪种Vehicle，再由driver决定调用v的哪个方法
	public void driveVehicle(Driver driver, Vehicle v) {
		driver.drives(v);
	}
	
	public static void main(String[] args) {
		//创建Driver抽象对象数组
		Driver[] drivers = new Driver[2];
		//drivers[0]存放子类对象FemaleDriver
		drivers[0] = new FemaleDriver();
		//drivers[1]存放子类对象MaleDriver
		drivers[1] = new MaleDriver();
		DoubleDispatching ma = new DoubleDispatching();
		ma.driveVehicle(drivers[0], new Bus());
		ma.driveVehicle(drivers[1], new Car());
	}
}